Public Class frmContrattiInvalidati

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Private Sub frmContrattiInvalidati_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dsDataset As New DataSet
        Dim dvVista As DataView
        Dim cnNW As New OleDb.OleDbConnection(strConnessioneClienti)
        Dim strSql As String = "SELECT T.KEY_ID, COGNOME, NOME, INDIRIZZO, CITTA, PROVINCIA, CAP, TELEFONO FROM (CONTRATTI T INNER JOIN CLIENTI C ON T.CODICE_CLIENTE=C.KEY_ID)  WHERE NONVALIDO=TRUE"
        Dim daLettore As New OleDb.OleDbDataAdapter(strSql, cnNW)

        daLettore.Fill(dsDataset, "elenco")
        If dsDataset.Tables("elenco").Rows.Count <> 0 Then
            dvVista = dsDataset.Tables("elenco").DefaultView
            flxGriglia.DataSource = dvVista
            flxGriglia.Columns(0).Visible = False
            dsDataset = Nothing
            cnNW.Close()
        Else
            MsgBox("Nessun contratto non valido in archivio", MsgBoxStyle.Information, "Contratti non validi")
            Me.Close()
        End If
    End Sub

    Private Sub flxGriglia_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles flxGriglia.KeyDown
        If e.KeyCode = Keys.Escape Then
            Me.Close()
        End If
    End Sub
End Class